<template>
  <div class="stepOne">
    <el-container>
      <el-aside width="200px"
        ><div class="asideFont"><i class="el-icon-collection-tag"></i><span>选择分类</span></div></el-aside
      >
      <el-main
        ><el-cascader-panel
          ref="cascaderRef"
          change-on-select
          v-model="cascaderValue"
          @change="cascaderChange()"
          style="height:400px;margin:50px"
          :options="options"
          :props="setCascader"
        ></el-cascader-panel>
        <p class="textWrning">
          当前选择 <span>{{ showArr }}</span>
        </p>
        <el-button class="btn" type="primary" @click="stepTwo()">下一步，填写商品信息</el-button></el-main
      >
    </el-container>
  </div>
</template>
<script>
export default {
  data() {
    return {
      options: [],
      setCascader: { value: 'name', label: 'name', children: 'categoryList' },
      cascaderValue: '',
      showArr: '',
      jumpId: ''
    }
  },
  methods: {
    async getCateData() {
      const { data: res } = await this.$http.post('/category/addCatgory')
      console.log(res.data)
      this.options = res.data
    },
    cascaderChange() {
      this.jumpId = this.$refs['cascaderRef'].getCheckedNodes()[0].data.id
      console.log(this.$refs['cascaderRef'].getCheckedNodes()[0].data.id)
      this.showArr = this.cascaderValue.join('>')
      localStorage.setItem('cate', this.showArr)
    },
    stepTwo() {
      if (this.jumpId === '') {
        this.$message('请选择分类')
      } else {
        this.$router.push('/goods/add/step2/' + this.jumpId)
      }
    }
  },
  created() {
    this.getCateData()
  }
}
</script>
<style lang="less" scoped>
.stepOne .el-container {
  border: 1px solid #ccc;
  height: 600px;
  width: 85%;
  margin-left: 100px;
  margin-top: 35px;
  .el-aside {
    border-right: 1px solid #ccc;
    overflow: none;
    position: relative;
    .asideFont {
      background: #666666;
      color: #fff;
      font-size: 25px;
      position: absolute;
      width: 100%;
      text-align: center;
      height: 55px;
      line-height: 55px;
      top: 45px;
      // &::after {
      //   content: '';
      //   position: absolute;
      //   right: -56px;
      //   border-right: 30px solid transparent;
      //   border-top: 30px solid transparent;
      //   border-left: 30px solid #666666;
      //   border-bottom: 30px solid transparent;
      //   z-index: 99999;
      // }
    }
  }
  .el-main {
    position: relative;
    .btn {
      position: absolute;
      right: 55px;
      bottom: 35px;
    }
    .textWrning {
      margin-left: 45px;
      color: orange;
      font-size: 20px;
      span {
        font-size: 15px;
        color: red;
      }
    }
  }
}
</style>
